package my_class.reflect;

import java.lang.reflect.Field;

public class Test4 {
    public static void main(String[] args) throws Exception {
        Class<?> clazz = Class.forName("my_class.reflect.Student");
        Object o = clazz.getConstructor().newInstance();
        Field name = clazz.getDeclaredField("name");
        name.setAccessible(true);
        System.out.println(name.get(o));
        System.out.println(o);
        name.set(o, "nanako");
        System.out.println(name.get(o));
        System.out.println(o);

        Field num = clazz.getDeclaredField("num");
        num.setAccessible(true);
        System.out.println("num.get(o) = " + num.get(o));

    }
}
